package com.topvision.service.api.impl.user;

import com.topvision.mapper.user.UserMapper;
import com.topvision.model.hes.HesUser;

import com.topvision.service.api.user.UserService;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public int insert(HesUser record) throws Exception {

        return userMapper.insert(record);
    }

    @Override
    public int insertSelective(HesUser record) throws Exception {
        return userMapper.insertSelective(record);
    }

    @Override
    public HesUser getUserByJobNumber(String jobNumber) throws Exception {
        System.out.println(userMapper);
        return userMapper.getUserByJobNumber(jobNumber);
    }

    @Override
    public HesUser Login(String username, String password) throws Exception {
        return userMapper.Login(username, password);
    }

    @Override
    public Map<String, Object> getPersonnelMattersStatus(String jobNumber) throws Exception {
        return userMapper.getPersonnelMattersStatus(jobNumber);
    }

    @Override
    public int updatePasswordByJobNumber(String jobNumber, String password) {
        Map<String, Object> map = new HashedMap();
        map.put("jobNumber", jobNumber);
        map.put("pass", password);
        return userMapper.updatePasswordByJobNumber(map);
    }

    @Override
    public int update(HesUser user) throws Exception {
        return userMapper.update(user);
    }

    @Override
    public int updateInfoByJobNumber(Map<String, Object> params) {
        return userMapper.updateInfoByJobNumber(params);
    }

    @Override
    public int changeGrant(HesUser user) throws Exception {
        return userMapper.changeGrant(user);
    }

    @Override
    public HesUser getUserByUserName(String username) {
        return userMapper.getUserByUserName(username);
    }

}
